package com.sinochem.ubmp.app;

import android.app.Application;

import com.facebook.react.ReactApplication;
import com.pilloxa.backgroundjob.BackgroundJobPackage;
import com.oblador.keychain.KeychainPackage;
import com.rnfingerprint.FingerprintAuthPackage;
import com.microsoft.codepush.react.CodePush;
import com.horcrux.svg.SvgPackage;
import com.masteratul.exceptionhandler.ReactNativeExceptionHandlerPackage;
import com.swmansion.gesturehandler.react.RNGestureHandlerPackage;
import com.oblador.vectoricons.VectorIconsPackage;
import org.devio.rn.splashscreen.SplashScreenReactPackage;
import org.wonday.pdf.RCTPdfView;
import com.RNFetchBlob.RNFetchBlobPackage;
import org.wonday.pdf.RCTPdfView;
import com.RNFetchBlob.RNFetchBlobPackage;
import com.reactnativecomponent.barcode.RCTCapturePackage;
import org.lovebing.reactnative.baidumap.BaiduMapPackage;
import com.facebook.react.modules.upgrade.UpgradePackage;
import com.imagepicker.ImagePickerPackage;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.modules.network.AppMainReactPackage;
import com.facebook.soloader.SoLoader;
import com.learnium.RNDeviceInfo.RNDeviceInfo;

import java.util.Arrays;
import java.util.List;

import cn.jpush.reactnativejpush.JPushPackage;

public class MainApplication extends Application implements ReactApplication {

  // 设置为 true 将不弹出 toast
  private boolean SHUTDOWN_TOAST = false;

  // 设置为 true 将不打印 log
  private boolean SHUTDOWN_LOG = false;

  private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {

    @Override
    protected String getJSBundleFile() {
      return CodePush.getJSBundleFile();
    }

    @Override
    public boolean getUseDeveloperSupport() {
      return BuildConfig.DEBUG;
    }

    @Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(new AppMainReactPackage(), new SplashScreenReactPackage(),
          new ImagePickerPackage(), // 摄像头
          new BackgroundJobPackage(),
          new RNDeviceInfo(), new UpgradePackage(), new BaiduMapPackage(getApplicationContext()),
          new RCTCapturePackage(), new JPushPackage(SHUTDOWN_TOAST, SHUTDOWN_LOG), new RNFetchBlobPackage(),
          new RCTPdfView(), new RNGestureHandlerPackage(), new SvgPackage(), new ReactNativeExceptionHandlerPackage(),
          new FingerprintAuthPackage(), new KeychainPackage(), new CodePush("N1d1kUq2sUFYAbscGzm0Bv5vrAJM4ksvOXqog",
              MainApplication.this, BuildConfig.DEBUG, "https://update.sinochemhx.com/"));
    }

    @Override
    protected String getJSMainModuleName() {
      return "index";
    }
  };

  @Override
  public ReactNativeHost getReactNativeHost() {
    return mReactNativeHost;
  }

  @Override
  public void onCreate() {
    super.onCreate();
    SoLoader.init(this, /* native exopackage */ false);
  }
}
